- placeholder = local_assigns[:search_form_placeholder] ? search_form_placeholder : _('Filter by name')
- admin_view ||= false
- top_padding = admin_view ? 'gl-lg-pt-3' : ''

= form_tag filter_projects_path, method: :get, class: "project-filter-form gl-display-flex! gl-flex-wrap gl-w-full gl-gap-3 #{top_padding}", data: { qa_selector: 'project_filter_form_container' }, id: 'project-filter-form' do |f|
  = search_field_tag :name, params[:name],
    placeholder: placeholder,
    class: "project-filter-form-field form-control input-short js-projects-list-filter gl-m-0!",
    spellcheck: false,
    id: 'project-filter-form-field',
    autofocus: local_assigns[:autofocus]

  - if local_assigns[:icon]
    = sprite_icon('search', css_class: 'search-icon')

  - if params[:sort].present?
    = hidden_field_tag :sort, params[:sort]

  - if params[:personal].present?
    = hidden_field_tag :personal, params[:personal]

  - if params[:archived].present?
    = hidden_field_tag :archived, params[:archived]

  - if params[:visibility_level].present?
    = hidden_field_tag :visibility_level, params[:visibility_level]

  - if params[:language].present?
    = hidden_field_tag :language, params[:language]

  .dropdown{ class: 'gl-m-0!' }
    = dropdown_toggle(search_language_placeholder, { toggle: 'dropdown', testid: 'project-language-dropdown' })
    %ul.dropdown-menu.dropdown-menu-right.dropdown-menu-selectable
      %li
        = link_to _('Any'), filter_projects_path(language: nil, name: nil)
      - programming_languages.each do |language|
        %li
          = link_to filter_projects_path(language: language.id, name: nil), class: language_state_class(language) do
            = language.name

  = submit_tag nil, class: 'gl-display-none!'

  = render 'shared/projects/dropdown'

  = render_if_exists 'shared/projects/search_fields'

  - if admin_view
    - if params[:namespace_id].present?
      - namespace = Namespace.find(params[:namespace_id])
    - selected_text = "#{namespace.kind}: #{namespace.full_path}" if namespace
    .gl-display-flex.gl-w-full.gl-md-w-auto{ class: 'gl-m-0!' }
      .js-namespace-select{ data: { field_name: 'namespace_id', selected_id: namespace&.id, selected_text: selected_text, update_location: 'true' } }

    = link_button_to new_project_path, class: 'gl-display-inline gl-mb-0!', variant: :confirm do
      = _('New Project')
